//
//  LGFollowDetailBasicInfoCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/26.
//  基本信息

#import "LGFollowDetailBasicInfoCell.h"
#import "LGFollowPressureView.h"
@interface LGFollowDetailBasicInfoCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *typeTitle;
/**   */
@property (nonatomic , strong)UILabel *typeContent;
/**   */
@property (nonatomic , strong)UILabel *bmiTitle;
/**   */
@property (nonatomic , strong)UILabel *bmiDateLabel;
/**   */
@property (nonatomic , strong)UILabel *heightLabel;
/**   */
@property (nonatomic , strong)UILabel *weightLabel;
/**   */
@property (nonatomic , strong)UILabel *pressureTitle;
/**   */
@property (nonatomic , strong)LGFollowPressureView *pressureView;
/**   */
@property (nonatomic , strong)UILabel *heartTitle;
/**   */
@property (nonatomic , strong)UILabel *heartDate;
/**   */
@property (nonatomic , strong)UILabel *heartContent;

@end

@implementation LGFollowDetailBasicInfoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    NSArray *typeArray = dataDic[@"disease"];
    NSString *typeString = @"";
    for (NSInteger i=0; i<typeArray.count; i++) {
        typeString = (typeString.length>0)?[NSString stringWithFormat:@"%@、%@",typeString,typeArray[i]]:typeArray[i];
    }
    self.typeContent.text = typeString;
    self.bmiDateLabel.text = LGNSString(dataDic[@"bmi"][@"bmi_date"]);
    self.heightLabel.text = [NSString stringWithFormat:@"%@ cm",dataDic[@"bmi"][@"height"]];
    self.weightLabel.text = [NSString stringWithFormat:@"%@ kg",dataDic[@"bmi"][@"weight"]];
    self.pressureView.dataDic = [NSMutableDictionary dictionaryWithDictionary:dataDic[@"bp"]];
}

-(void)setHeartDic:(NSDictionary *)heartDic{
    _heartDic = heartDic;
    NSString *dateString = LGNSString(heartDic[@"nyhadate"]);
    self.heartDate.text = dateString;
    self.heartContent.hidden = (dateString.length>0)?NO:YES;
    self.heartContent.text = heartDic[@"nyharesult"];
}

-(void)createSubView{
    self.clipsToBounds = YES;
    self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.baseView];
    [self.contentView addSubview:self.typeTitle];
    [self.contentView addSubview:self.typeContent];
    [self.contentView addSubview:self.bmiTitle];
    [self.contentView addSubview:self.bmiDateLabel];
    [self.contentView addSubview:self.heightLabel];
    [self.contentView addSubview:self.weightLabel];
    [self.contentView addSubview:self.pressureTitle];
    [self.contentView addSubview:self.pressureView];
    [self.contentView addSubview:self.heartTitle];
    [self.contentView addSubview:self.heartDate];
    [self.contentView addSubview:self.heartContent];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(-viewPix(15));
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.bottom.equalTo(self.contentView).offset(-viewPix(10));
    }];
    [self.typeTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(32));
        make.top.equalTo(self.contentView).offset(viewPix(10));
    }];
    [self.typeContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.typeTitle.mas_bottom).offset(viewPix(8));
        make.left.equalTo(self.contentView).offset(viewPix(32));
        make.right.equalTo(self.contentView).offset(-viewPix(32));
    }];
    [self.bmiTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.typeContent.mas_bottom).offset(viewPix(15));
        make.left.equalTo(self.typeTitle);
    }];
    [self.bmiDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bmiTitle.mas_bottom).offset(viewPix(8));
        make.left.equalTo(self.bmiTitle);
    }];
    [self.heightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bmiDateLabel);
        make.centerX.equalTo(self.contentView);
    }];
    [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bmiDateLabel);
        make.right.equalTo(self.contentView).offset(-viewPix(55));
    }];
    [self.pressureTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bmiDateLabel.mas_bottom).offset(viewPix(15));
        make.left.equalTo(self.typeTitle);
    }];
    [self.pressureView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pressureTitle.mas_bottom).offset(viewPix(8));
        make.left.equalTo(self.contentView).offset(viewPix(28));
        make.right.equalTo(self.contentView).offset(-viewPix(28));
        make.height.equalTo(@(viewPix(68)));
    }];
    [self.heartTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pressureView.mas_bottom).offset(viewPix(15));
        make.bottom.equalTo(self.contentView).offset(-viewPix(50));
        make.left.equalTo(self.typeTitle);
    }];
    [self.heartDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.heartTitle.mas_bottom).offset(viewPix(8));
        make.left.equalTo(self.heartTitle);
    }];
    [self.heartContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.heartDate);
        make.right.equalTo(self.contentView).offset(-viewPix(32));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:10];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)typeTitle{
    if(!_typeTitle){
        _typeTitle = [UILabel lableWithText:@"共病类型" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _typeTitle;
}

-(UILabel *)typeContent{
    if(!_typeContent){
        _typeContent = [UILabel lableWithText:@"高血压、糖尿病" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _typeContent;
}

-(UILabel *)bmiTitle{
    if(!_bmiTitle){
        _bmiTitle = [UILabel lableWithText:@"最新身高体重" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _bmiTitle;
}

-(UILabel *)bmiDateLabel{
    if(!_bmiDateLabel){
        _bmiDateLabel = [UILabel lableWithText:@"2023-02-25" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _bmiDateLabel;
}

-(UILabel *)heightLabel{
    if(!_heightLabel){
        _heightLabel = [UILabel lableWithText:@"170.6" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _heightLabel;
}

-(UILabel *)weightLabel{
    if(!_weightLabel){
        _weightLabel = [UILabel lableWithText:@"170.6" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _weightLabel;
}

-(UILabel *)pressureTitle{
    if(!_pressureTitle){
        _pressureTitle = [UILabel lableWithText:@"最新血压心率" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _pressureTitle;
}

-(LGFollowPressureView *)pressureView{
    if(!_pressureView){
        _pressureView = [[LGFollowPressureView alloc] initWithFrame:CGRectMake(viewPix(12), kMaxY(self.pressureTitle.frame)+viewPix(8), Screen_W-viewPix(56), viewPix(68))];
        _pressureView.layer.borderColor = [UIColor colorWithString:@"#E0E0E0"].CGColor;
        _pressureView.layer.borderWidth = 1;
        _pressureView.cornerRidus = 7;
        _pressureView.canEdit = NO;
    }
    return _pressureView;
}

-(UILabel *)heartTitle{
    if(!_heartTitle){
        _heartTitle = [UILabel lableWithText:@"心功能等级" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _heartTitle;
}

-(UILabel *)heartDate{
    if(!_heartDate){
        _heartDate = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _heartDate;
}

-(UILabel *)heartContent{
    if(!_heartContent){
        _heartContent = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _heartContent;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
